#ifndef _BINARY_TREE_H_
#define _BINARY_TREE_H_ 
#include "lib.h"

typedef struct _binary_tree_node_  { 
	unsigned int	data; 					/*value of node */
	struct _binary_tree_node_ *left; 	/* left child of node */
	struct _binary_tree_node_ *right; 	/* right child of node */ 
} binary_tree_node_s; 

struct _binary_tree_s_ {
	binary_tree_node_s	 *root;
};

struct _binary_tree_s_;
typedef struct _binary_tree_s_ binary_tree_s;

typedef ret_e (*loop_func)( int data,void *context);
binary_tree_s *binary_tree_create(void);
ret_e  binary_tree_add_data(binary_tree_s *tree,int data);
ret_e binary_tree_print(binary_tree_s *tree,loop_func loop_fun);
void dlist_for_loop(void*root,loop_func loop_fun);
void * tree_to_dlist(binary_tree_s*tree);
void binary_tree_display(binary_tree_node_s *root) ;
void  binary_tree_mid_out_by_recursion(binary_tree_node_s *root,loop_func print_fun);
void  binary_tree_pre_out_by_recursion(binary_tree_node_s *root,loop_func print_fun);
int  binary_tree_pre_out_by_non_recursion(binary_tree_node_s *root,loop_func print_fun,void **context);
void  binary_tree_last_out_by_non_recursion(binary_tree_node_s *root,loop_func print_fun);
void  binary_tree_last_out_by_recursion(binary_tree_node_s *root,loop_func print_fun);
binary_tree_node_s * binary_tree_build_by_mid_and_pre(int *pre,int *mid,int len);
int   binary_tree_mid_out_by_non_recursion(binary_tree_node_s *root,loop_func print_fun,void **context);

#endif
